package com.why.servicecms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.why.servicecms.bean.CrmBanner;
import com.why.servicecms.mapper.CrmBannerMapper;
import com.why.servicecms.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author why
 * @since 2021-02-14
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

    @Cacheable(key = "'bannerData'",value = "banner")
    @Override
    public List<CrmBanner> selectIndexList() {

        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();

        wrapper.orderByDesc(true, "gmt_modified");
        wrapper.last("limit 2");
        return baseMapper.selectList(wrapper);
    }
}
